/**
 * 文  件  名：  RemindInfoDaoProxy.java
 * 工  程  名：  7You
 * 创建日期：  2013-10-14
 * 创建作者：  杨  强
 */
package com.qiyou.dao.proxy;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import com.qiyou.dao.IRemindInfoDao;
import com.qiyou.dao.impl.RemindInfoDaoImpl;
import com.qiyou.db.IDatabase;
import com.qiyou.entity.RemindInfo;
import com.qiyou.util.DBUtil;

/**
 * 提醒消息数据操作代理类
 * 
 * @author 杨 强
 * 
 */
public class RemindInfoDaoProxy implements IRemindInfoDao {
    private Connection conn = null;
    private IRemindInfoDao dao = null;

    public RemindInfoDaoProxy(IDatabase database) {
        this.conn = database.getConnection();
        this.dao = new RemindInfoDaoImpl(conn);
    }

    @Override
    public boolean doCreate(RemindInfo remindInfo) throws SQLException {
        boolean result = false;
        if (null != remindInfo) {
            try {
                result = dao.doCreate(remindInfo);
            } catch (SQLException e) {
                throw e;
            } finally {
                DBUtil.closeConnection(conn);
            }
        }
        return result;
    }

    @Override
    public boolean doUpdate(RemindInfo remindInfo) throws SQLException {
        boolean result = false;
        if (null != remindInfo) {
            try {
                result = dao.doUpdate(remindInfo);
            } catch (SQLException e) {
                throw e;
            } finally {
                DBUtil.closeConnection(conn);
            }
        }
        return result;
    }

    @Override
    public boolean doDelete(long remindInfoID) throws SQLException {
        boolean result = false;
        try {
            result = dao.doDelete(remindInfoID);
        } catch (SQLException e) {
            throw e;
        } finally {
            DBUtil.closeConnection(conn);
        }
        return result;
    }

    @Override
    public RemindInfo getRemindInfo(long remindInfoID) throws SQLException {
        RemindInfo result = null;
        try {
            result = dao.getRemindInfo(remindInfoID);
        } catch (SQLException e) {
            throw e;
        } finally {
            DBUtil.closeConnection(conn);
        }
        return result;
    }

    @Override
    public List<RemindInfo> getRemindInfos(String userID) throws SQLException {
        List<RemindInfo> result = null;
        if ((null != userID) && (!userID.isEmpty())) {
            try {
                result = dao.getRemindInfos(userID);
            } catch (SQLException e) {
                throw e;
            } finally {
                DBUtil.closeConnection(conn);
            }
        }
        return result;
    }

    @Override
    public List<RemindInfo> getRemindInfos(Object... params)
            throws SQLException {
        List<RemindInfo> result = null;
        if (null != params) {
            try {
                result = dao.getRemindInfos(params);
            } catch (SQLException e) {
                throw e;
            } finally {
                DBUtil.closeConnection(conn);
            }
        }
        return result;
    }

}
